package entity;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Embeddable
public class InvitationPK implements Serializable {

    @Basic(optional = false)
    @NotNull
    @Column(name = "eventId")
    private int eventId;

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "senderUsername")
    private String senderUsername;

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "receiverUsername")
    private String receiverUsername;

    public InvitationPK() {
    }

    public InvitationPK(int eventId, String senderUsername, String receiverUsername) {
        this.eventId = eventId;
        this.senderUsername = senderUsername;
        this.receiverUsername = receiverUsername;
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public String getSenderUsername() {
        return senderUsername;
    }

    public void setSenderUsername(String senderUsername) {
        this.senderUsername = senderUsername;
    }

    public String getReceiverUsername() {
        return receiverUsername;
    }

    public void setReceiverUsername(String receiverUsername) {
        this.receiverUsername = receiverUsername;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) eventId;
        hash += (senderUsername != null ? senderUsername.hashCode() : 0);
        hash += (receiverUsername != null ? receiverUsername.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof InvitationPK)) {
            return false;
        }
        InvitationPK other = (InvitationPK) object;
        if (this.eventId != other.eventId) {
            return false;
        }
        if (!Objects.equals(senderUsername, other.senderUsername)) {
            return false;
        }
        return Objects.equals(this.receiverUsername, other.receiverUsername);
    }

    @Override
    public String toString() {
        return "entity.InvitationPK[ eventId=" + eventId + ", senderUsername=" + senderUsername + ", receiverUsername=" + receiverUsername + " ]";
    }

}
